package com.mchsdk.paysdk.activity.fragments;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.text.TextUtils;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.TextView;

import com.mchsdk.paysdk.bean.PersonalCenterModel;
import com.mchsdk.paysdk.utils.MCHInflaterUtils;

/**
 * Created by LeBron on 2017/5/4.
 */

public class ToCertificateFragment extends Fragment{
    private View inflate;
    private FragmentActivity activity;
    TextView id_card;
    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        inflate = inflater.inflate(MCHInflaterUtils.getLayout(getActivity(), "to_certificate_fragment"), null);

        activity = getActivity();

        Button button = (Button) inflate.findViewById(MCHInflaterUtils
                .getControl(activity, "mch_attestation_button_person"));
        button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                activity.finish();
            }
        });
        TextView real_name = (TextView) inflate.findViewById(MCHInflaterUtils
                .getControl(activity, "mch_certificate_real_name"));
         real_name.setText(PersonalCenterModel.getInstance().getReal_name());
        id_card = (TextView) inflate.findViewById(MCHInflaterUtils
                .getControl(activity, "mch_certificate_id_card"));


        String idCard = PersonalCenterModel.getInstance().getIdcard();
        if(!TextUtils.isEmpty(idCard)&&idCard.length()>14)
        {
            StringBuffer stringBuffer = new StringBuffer(idCard);
            String xing = "";
            for (int i = 1;i<id_card.length()-1;i++){
                xing = xing+"*";
            }
            stringBuffer.replace(1,idCard.length()-1,xing);
            id_card.setText(stringBuffer.toString());
        }

        return inflate;
    }

}
